/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Yeast")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Yeast.findAll", query = "SELECT y FROM Yeast y"),
    @NamedQuery(name = "Yeast.findByYid", query = "SELECT y FROM Yeast y WHERE y.yid = :yid"),
    @NamedQuery(name = "Yeast.findByYeastName", query = "SELECT y FROM Yeast y WHERE y.yeastName = :yeastName"),
    @NamedQuery(name = "Yeast.findByYeastDesc", query = "SELECT y FROM Yeast y WHERE y.yeastDesc = :yeastDesc"),
    @NamedQuery(name = "Yeast.findByYeastActive", query = "SELECT y FROM Yeast y WHERE y.yeastActive = :yeastActive"),
    @NamedQuery(name = "Yeast.findByYeastBasePitchRate", query = "SELECT y FROM Yeast y WHERE y.yeastBasePitchRate = :yeastBasePitchRate"),
    @NamedQuery(name = "Yeast.findByYeastAdditionalPitchRate", query = "SELECT y FROM Yeast y WHERE y.yeastAdditionalPitchRate = :yeastAdditionalPitchRate"),
    @NamedQuery(name = "Yeast.findByMaxGen", query = "SELECT y FROM Yeast y WHERE y.maxGen = :maxGen"),
    @NamedQuery(name = "Yeast.findByYeastCost", query = "SELECT y FROM Yeast y WHERE y.yeastCost = :yeastCost"),
    @NamedQuery(name = "Yeast.findByYeastOrderVol", query = "SELECT y FROM Yeast y WHERE y.yeastOrderVol = :yeastOrderVol")})
public class Yeast implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "YID")
    private Integer yid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 80)
    @Column(name = "YeastName")
    private String yeastName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 100)
    @Column(name = "YeastDesc")
    private String yeastDesc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YeastActive")
    private boolean yeastActive;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YeastBasePitchRate")
    private float yeastBasePitchRate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YeastAdditionalPitchRate")
    private float yeastAdditionalPitchRate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MaxGen")
    private int maxGen;
    @Basic(optional = false)
    @NotNull
    @Column(name = "yeastCost")
    private float yeastCost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "yeastOrderVol")
    private float yeastOrderVol;
    @OneToMany(mappedBy = "yeastName")
    private Collection<Recipes> recipesCollection;
    @OneToOne
    @JoinTable(
        name="JTYeastToStock",
        joinColumns={ @JoinColumn(name="YID", referencedColumnName="YID", unique=true)},
        inverseJoinColumns={ @JoinColumn(name="StockID", referencedColumnName="StockID", unique=true)}
    )
    private StockCode stockCode;

    public Yeast() {
    }

    public Yeast(Integer yid) {
        this.yid = yid;
    }

    public Yeast(Integer yid, String yeastName, String yeastDesc, boolean yeastActive, float yeastBasePitchRate, float yeastAdditionalPitchRate, int maxGen, float yeastCost, float yeastOrderVol) {
        this.yid = yid;
        this.yeastName = yeastName;
        this.yeastDesc = yeastDesc;
        this.yeastActive = yeastActive;
        this.yeastBasePitchRate = yeastBasePitchRate;
        this.yeastAdditionalPitchRate = yeastAdditionalPitchRate;
        this.maxGen = maxGen;
        this.yeastCost = yeastCost;
        this.yeastOrderVol = yeastOrderVol;
    }

    public Integer getYid() {
        return yid;
    }

    public void setYid(Integer yid) {
        this.yid = yid;
    }

    public String getYeastName() {
        return yeastName;
    }

    public void setYeastName(String yeastName) {
        this.yeastName = yeastName;
    }

    public String getYeastDesc() {
        return yeastDesc;
    }

    public void setYeastDesc(String yeastDesc) {
        this.yeastDesc = yeastDesc;
    }

    public boolean getYeastActive() {
        return yeastActive;
    }

    public void setYeastActive(boolean yeastActive) {
        this.yeastActive = yeastActive;
    }

    public float getYeastBasePitchRate() {
        return yeastBasePitchRate;
    }

    public void setYeastBasePitchRate(float yeastBasePitchRate) {
        this.yeastBasePitchRate = yeastBasePitchRate;
    }

    public float getYeastAdditionalPitchRate() {
        return yeastAdditionalPitchRate;
    }

    public void setYeastAdditionalPitchRate(float yeastAdditionalPitchRate) {
        this.yeastAdditionalPitchRate = yeastAdditionalPitchRate;
    }

    public int getMaxGen() {
        return maxGen;
    }

    public void setMaxGen(int maxGen) {
        this.maxGen = maxGen;
    }

    public float getYeastCost() {
        return yeastCost;
    }

    public void setYeastCost(float yeastCost) {
        this.yeastCost = yeastCost;
    }

    public float getYeastOrderVol() {
        return yeastOrderVol;
    }

    public void setYeastOrderVol(float yeastOrderVol) {
        this.yeastOrderVol = yeastOrderVol;
    }

    public StockCode getStockCode() {
        return stockCode;
    }

    public void setStockCode(StockCode stockCode) {
        this.stockCode = stockCode;
    }

    @XmlTransient
    public Collection<Recipes> getRecipesCollection() {
        return recipesCollection;
    }

    public void setRecipesCollection1(Collection<Recipes> recipesCollection) {
        this.recipesCollection = recipesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (yid != null ? yid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Yeast)) {
            return false;
        }
        Yeast other = (Yeast) object;
        if ((this.yid == null && other.yid != null) || (this.yid != null && !this.yid.equals(other.yid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.Yeast[ yid=" + yid + " ]";
    }
    
}
